#include <unordered_map>
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        // hash表储存 {nums[i], i}
        unordered_map<int, int> umap;

        for(int i = 0; i < nums.size(); i++){
            auto flag = umap.find(target - nums[i]);
            if(flag != umap.end()){
                return {i, umap.at(target - nums[i])};
            }
            umap.insert({nums[i], i});
        }
        return {};
    }
};